//引入核心库
import Vue from 'vue';
// 引入路由
import VueRouter from 'vue-router';
import routes from '@/router/routes'
// 使用路由
Vue.use(VueRouter)
// 解决编程式导航跳转相同路由地址控制台报错问题
// 重写路由规则
let routerPush= VueRouter.prototype.push
let routerReplace= VueRouter.prototype.replace;
// 重写push方法
VueRouter.prototype.push=function(location,resolved,rejected){
    if(resolved||rejected) return routerPush.call(this,location,resolved,rejected)
     return  routerPush.call(this,location).catch(err=>err) 
}
// 重写replace方法
VueRouter.prototype.replace=function(location,resolved,rejected){
    if(resolved||rejected)return routerReplace.call(this,location,resolved,rejected)
    return routerReplace.call(this,location).catch(err=>err)
}
const router = new VueRouter({
    mode:'history',
    routes
    
})
// 暴漏
export default router